<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>修改订单</title>
<!--公共样式开始-->
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Css/reset.css">
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Css/common.css">
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Plugins/FontAwesome/css/font-awesome.min.css">
<!--公共样式结束-->
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Css/module_form.css">
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Css/page_memberAdd.css">
<script src="{$NOW_THEME_URL}/Assets/Js/jquery.min.js"></script>
<script src="{$NOW_THEME_URL}/Assets/Js/jquery.timer.js"></script>
<script src="{$NOW_THEME_URL}/Assets/Js/common.js"></script>
<script src="__PUBLIC__/Plugins/Datepicker/WdatePicker.js"></script>
<style>
.attr{
	margin-left:30px;
}
.editbtn{
	background-color:#339900;
	color:#FFFFFF;
	padding:2px 4px;
	cursor:pointer;
	border:0px;
}
.ele_title{
	font-size:16px;
	font-weight:bold;
	width:108px;
}
.attr_list{
	background-color:green;
	margin-right:5px;
	color:#FFFFFF;
}
.addressdl{
	width:400px;
	border:1px solid #ccc;
	box-shadow:1px 2px 4px rgba(0,0,0,0.1) inset;
	display:none;
}
.addressdl dl dd{
	line-height:15px;
	cursor:pointer;
}
.addressdl dl .ditu{
	background:#10AE5C;
	text-align:center;
	cursor:default;
}
.addressdl dl .ditu img{
	cursor:pointer;
}
.addressdl dl dd span{
	display:block;
	padding:5px;
}
.addressdl dl dd:hover{
	background:#0774B9;
	color:#fff;
}
</style>
</head>

<body>
	<div class="page_wraper">
	<form method="post" id="restaurantAdd_form">
		<div id="tab1_0" fortab="tab1">
			<table cellpadding="0" cellspacing="0" class="module_form" width="600">
			<input type="hidden" value="{$Think.get.id}" id="userid" name="userid">
			<input type="hidden" name="addid" id="addid">
			<input type="hidden" name="pointlng" id="pointlng">
			<input type="hidden" name="pointlat" id="pointlat">
			<input type="hidden" name="cityname" id="cityname">
			
				<tr>
					<td class="ele_title"><label for="cardnum">所属城市：</label></td>
					<td class="ele_content" colspan="3">
						<select name="city" id="city">
							<option value="">请选择所属城市</option>
							<option value="850">北京</option>
							<option value="866">上海</option>
							<option value="867">广州</option>
							<option value="930">顺义</option>
						</select>
						<span class="editbtn" id="usemap" style="float:right;margin-right:20px">通过地图标注</span>
					</td>
				</tr>
				<tr>
					<td class="ele_title"><label for="cardnum">地址关键词：</label></td>
					<td class="ele_content" colspan="3">
						<input type="text" name="keywords" id="keywords"  placeholder="请输入关键字进行搜索" class="form_ele_text addressinput width_400"  autocomplete="off" onKeyUp="showAddress()" />
						<input type="button" id="clearbtn" class="editbtn" value="清空">
					</td> 
				</tr>
				<tr>
					<td class="ele_title"></td>
					<td class="ele_content" colspan="3">
						<div class="addressdl">
							<dl></dl>
						</div>
					</td>
				</tr>
				<tr>
					<td class="ele_title"><label for="cardnum">会员地址：</label></td>
					<td class="ele_content" colspan="3">
						<input type="text" name="address" id="address"  placeholder="请通过地址关键词或地图标注获取" class="form_ele_text width_400"/>
					</td> 
				</tr>
				<tr>
					<td class="ele_title"><label for="cardnum">详细地址：</label></td>
					<td class="ele_content" colspan="3">
						<input type="text" name="detail" id="detail"  placeholder="请输入关详细地址" class="form_ele_text width_400"/>
					</td> 
				</tr>
			</table>
		</div>
		</form>
	</div>
	<div class="page_footer pdtd10">
		<input type="button" name="submit" id="submit" value="确认"  class="form_ele_submit"/>
		<input type="reset" name="reset" id="reset" value="重置"  class="form_ele_reset"/>
	</div>
</body>
<script type="text/javascript">
	function showAddress(){
		var value  = $('.addressinput').val();
		var cityid = $('#city').val();
		
		if(value){
			$.get("{:U('Order/site')}",{value:value,cityid:cityid},function(data){
				if(data){
					$('.addressdl dl').html(data);
					$('.addressdl').slideDown();
					
					$('.addressdl dl dd span').click(function(){
						var html  = $(this).text();
						var addid = $(this).attr("did"); 
						
						$('.addressinput').val(html);
						$('#address').val(html);
						$('#addid').val(addid);
						
						$('.addressdl').slideUp(function(){
							$('.address_choose').slideDown();
						});
					});
				}else{
					var html = "没有找到相应的地址，您可以换一个关键词或者通过地图选址";
					$('.addressdl').slideUp();
					$('.address_choose').slideUp();
				}
			});
		}else{
			$('.addressdl').slideUp();
			return false;
		}
	}

	//弹出窗口全局变量
	var api = frameElement.api, W = api.opener;
	$(function(){
		//滑动门
		$('.tabbar li').click(function(){
			var tabname = $('.tabbar>ul').attr('tabname');
			$('.tabbar li').removeClass('tabhover');
			$(this).addClass('tabhover');
			
			$('div[fortab="'+tabname+'"]').hide();
			$('#'+$(this).attr('show')).show();
		});
		
		//表格隔行换色
		$('.module_form tr:odd').addClass('odd');
		$('.module_form tr:even').addClass('even');
		
		//表单操作
		//重置
		$('.form_ele_reset').on('click',function(){
			$('#restaurantAdd_form').get(0).reset();
		});
		
		//清空内容
		$('#clearbtn').on('click',function(){
			$('.addressinput').val('');
			$('.addressinput').focus();
		});
		
		//通过地图标注信息点
		$('#usemap').on('click',function(){
			var city     = $('#cityname').val();
			if(!city){
				windowApi.lhgdialog.alert('请选择所属城市');
			}else{
				var href     = "{:U('Custom/outletLbs')}&address="+city;
				var width    = '1000px';
				var height   = '500px';
				var title    = '添加会员地址标注信息点';
				openDialog('Custom_outletLbs',href,width,height,title);
			}
		});
		
		//获取城市
		$('#city > option').on('click',function(){
			$('#cityname').val($(this).text());
		});

		//提交表单
		$(".form_ele_submit").on("click",function(){
			
			var postData = {};
			var tipsObj = windowApi.lhgdialog.tips('正在提交数据...',10,etIcon.loading);
			postData = $("#restaurantAdd_form").serialize();
			
			$.post("{:U('Custom/address')}", postData ,function(d){
				if(d.status==1){
					tipsObj.close();
					windowApi.lhgdialog.tips('地址添加成功！',1,etIcon.success,function(){
						frameApi.close(); //关闭当前窗口
						var obj = windowApi.lhgdialog.list['Custom_index'];
						if(obj){
							obj.reload(obj);
						}else{
							var href     = "{:U('Custom/index')}";
							var width    = '1000px';
							var height   = '500px';
							var title    = '会员列表';
							openDialog('Custom_index',href,width,height,title);
						}
					});
				}else{
					windowApi.lhgdialog.alert(d.info);
				}
			}, "json");
		});
	});
</script>
</html>
